package com.bmit.clusterspring.mapper;

import com.bmit.clusterspring.model.InnerLog;
import com.bmit.clusterspring.model.InnerLogExample;

import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface InnerLogMapper {
    @SelectProvider(type = InnerLogSqlProvider.class, method = "countByExample")
    long countByExample(InnerLogExample example);

    @DeleteProvider(type = InnerLogSqlProvider.class, method = "deleteByExample")
    int deleteByExample(InnerLogExample example);

    @Delete({
            "delete from inner_log",
            "where log_id = #{logId,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long logId);

    @Insert({
            "insert into inner_log (log_id, ip_address, ",
            "run_time, dbi, di, ",
            "gmt_create)",
            "values (#{logId,jdbcType=BIGINT}, #{ipAddress,jdbcType=CHAR}, ",
            "#{runTime,jdbcType=DOUBLE}, #{dbi,jdbcType=DOUBLE}, #{di,jdbcType=DOUBLE}, ",
            "#{gmtCreate,jdbcType=TIMESTAMP})"
    })
    int insert(InnerLog record);

    @InsertProvider(type = InnerLogSqlProvider.class, method = "insertSelective")
    int insertSelective(InnerLog record);

    @SelectProvider(type = InnerLogSqlProvider.class, method = "selectByExample")
    @Results({
            @Result(column = "log_id", property = "logId", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "ip_address", property = "ipAddress", jdbcType = JdbcType.CHAR),
            @Result(column = "run_time", property = "runTime", jdbcType = JdbcType.DOUBLE),
            @Result(column = "dbi", property = "dbi", jdbcType = JdbcType.DOUBLE),
            @Result(column = "di", property = "di", jdbcType = JdbcType.DOUBLE),
            @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP)
    })
    List<InnerLog> selectByExample(InnerLogExample example);

    @Select({
            "select",
            "log_id, ip_address, run_time, dbi, di, gmt_create",
            "from inner_log",
            "where log_id = #{logId,jdbcType=BIGINT}"
    })
    @Results({
            @Result(column = "log_id", property = "logId", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "ip_address", property = "ipAddress", jdbcType = JdbcType.CHAR),
            @Result(column = "run_time", property = "runTime", jdbcType = JdbcType.DOUBLE),
            @Result(column = "dbi", property = "dbi", jdbcType = JdbcType.DOUBLE),
            @Result(column = "di", property = "di", jdbcType = JdbcType.DOUBLE),
            @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP)
    })
    InnerLog selectByPrimaryKey(Long logId);

    @UpdateProvider(type = InnerLogSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") InnerLog record, @Param("example") InnerLogExample example);

    @UpdateProvider(type = InnerLogSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") InnerLog record, @Param("example") InnerLogExample example);

    @UpdateProvider(type = InnerLogSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(InnerLog record);

    @Update({
            "update inner_log",
            "set ip_address = #{ipAddress,jdbcType=CHAR},",
            "run_time = #{runTime,jdbcType=DOUBLE},",
            "dbi = #{dbi,jdbcType=DOUBLE},",
            "di = #{di,jdbcType=DOUBLE},",
            "gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}",
            "where log_id = #{logId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(InnerLog record);

    @Select({
            "select di",
            "from inner_log"
    })
    @Results({
            @Result(column = "di", property = "di", jdbcType = JdbcType.DOUBLE),
    })
    List<Double> getDIs();

    @Select({
            "select dbi",
            "from inner_log"
    })
    @Results({
            @Result(column = "dbi", property = "dbi", jdbcType = JdbcType.DOUBLE),
    })
    List<Double> getDBIs();
}